<?php
namespace Admin\Controller;
use Think\Controller;
/*
后台评论管理  
 */
class 	CommentController extends CommonController {

	//展现
	public function comment_list()
	{
		$sql = "select t1.id,t1.content,t1.create_time,t2.status,t2.title,t3.nickname from answer t1 inner join question t2 on t1.uid=t2.id  inner join user t3 on t3.id=t1.uid ";
		$res = M()->query($sql);
		// var_dump($res);
		$count      = count($res);// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,6);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出

		$sql = "select t1.id,t1.content,t1.create_time,t2.status,t2.title,t3.nickname from answer t1 inner join question t2 on t1.uid=t2.id  inner join user t3 on t3.id=t1.uid limit ".$Page->firstRow.','.$Page->listRows;
		// $sql="select * from user limit ".$Page->firstRow.','.$Page->listRows;
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$res=M()->query($sql);

		$this->assign('page',$show);// 赋值分页输出
		$this->assign('res',$res);
		$this->display();
	}
	//删除
	public function comment_del()
	{
		$id = I('post.aid');
      $res = M('answer')->where("id='$id'")->delete();
      // var_dump($id);
      if ($res) {
        Reajax(0,"删除成功");
      }else{
        Reajax(1,"没有删除");
      }
	}




}
?>